﻿using System;
using System.Data;
using System.Linq;
using System.Windows;
using WPFExcelReport.Chart;
using System.Windows.Controls;
using WPFExcelReport.Helpers;
using System.ComponentModel;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class TSMVKART
    {

        public TSMVKART()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVKPOS();
            this.DataContext = MV; 
            InitializeComponent(); 
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            if (dwMain == null)
            {
            }
            if (TMV.VKPART.Trim().Length > 2)
            {
                TXTISIND = (TMV.VKPAUFKRS + TMV.VKPAUFLFD + TMV.VKPKOLL + TMV.VKPART).PadRight(60);

            }
            else
            {

                TXTISIND = "";
            }
        }
        public override void OnEXAUFChg(string vlaue)
        {
            if (IsCanLoad)
                return;
            if (EXAUF.Length == 0)
                return; 
            dwData = TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPSA"] = "  ";

            dwData["VKPAUFKRS"] = " AND VKPAUFKRS||VKPAUFLFD<>'" + EXAUF.Substring(0, 8) + "'";
            dwData["VKPART"] ="  AND VKPKOLL='"+EXAUF.Substring(8, 5)+"' AND VKPART='"+EXAUF.Substring(13, 24)+"'";
            ART = EXAUF.Substring(13, 24);
            SResult =TMV.QVKP31(dwData);
            MergeData(SResult, true);
            base.OnEXAUFChg(vlaue);
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPSA"] = "  ";
            if (KRS.Trim().Length > 0)
            {
                dwData["VKPAUFKRS"] = " AND VKPAUFKRS='" + KRS + "' AND VKPAUFLFD='" + LFD + "'";
            }
            
            dwData["VKPART"] =   " AND VKPART like '" + ART + "%'";
            SResult = TMV.QVKP31(dwData);
            MergeData(SResult, true);
            base.QueryCommand(sender, e);
        }
    }
     
}
